﻿#define _CRT_SECURE_NO_WARNINGS
//描述
//给你一个整数n，按要求输出n∗n的回型矩阵
//输入描述：
//输入一行，包含一个整数n
//
//1 <= n <= 19
//输出描述：
//输出n行，每行包含n个正整数.
//示例1
//输入：
//4
//复制
//输出：
//1 2 3 4
//12 13 14 5
//11 16 15 6
//10 9 8 7

#include <stdio.h>

int main()
{
    int n = 0;
    scanf("%d", &n);
    int arr[20][20] = { 0 };
    int i = 0;
    int j = 0;
    int up = 0, down = n - 1, left = 0, right = n - 1;
    int x = 1;
    while (x <= n * n)
    {
        for (i = left; i <= right; i++)
        {
            arr[up][i] = x++;
        }
        up++;
        for (i = up; i <= down; i++)
        {
            arr[i][right] = x++;
        }
        right--;
        for (i = right; i >= left; i--)
        {
            arr[down][i] = x++;
        }
        down--;
        for (i = down; i >= up; i--)
        {
            arr[i][left] = x++;
        }
        left++;
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
        {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}